<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
use Hyperf\HttpServer\Router\Router;

Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index');

Router::get('/favicon.ico', function () {
    return '';
});
/** 后台接口使用路由,api接口使用注解 **/
/**
 * fixme 不需要鉴权的接口
 */
Router::addGroup('/backend',function (){
    Router::addRoute(["get","post"],'/login', [App\Controller\Admin\AuthController::class,'login']);//登录
    Router::addRoute(["get","post"],'/logs', [App\Controller\Admin\ActionLogController::class,'logs']);//获取日志列表
});
/**
 * fixme 需要鉴权的接口
 */
Router::addGroup('/backend',function (){
    Router::addRoute(["get","post"],'/logout', [App\Controller\Admin\AdministratorController::class,'logout']);//退出登陆
    //菜单
    Router::addRoute(["get","post"],'/menus', [App\Controller\Admin\MenusController::class,'menus']);//获取菜单
    Router::addRoute(["get","post"],'/menus/tree', [App\Controller\Admin\MenusController::class,'tree']);//获取菜单列表
    Router::addRoute(["get","post"],'/menus/info', [App\Controller\Admin\MenusController::class,'info']);//获取某一个菜单的详情
    Router::addRoute(["get","post"],'/menus/menuAndChildren', [App\Controller\Admin\MenusController::class,'menuAndChildren']);//获取某一个菜单的详情
    Router::addRoute(["get","post"],'/menus/create', [App\Controller\Admin\MenusController::class,'create']);//创建菜单
    Router::addRoute(["get","post"],'/menus/update', [App\Controller\Admin\MenusController::class,'update']);//更新菜单
    Router::addRoute(["get","post"],'/menus/destroy', [App\Controller\Admin\MenusController::class,'destroy']);//删除菜单

    //权限
    Router::addRoute(["get","post"],'/permissions/tree', [App\Controller\Admin\PermissionsController::class,'tree']);//获取权限树
    Router::addRoute(["get","post"],'/permission/list', [App\Controller\Admin\PermissionsController::class,'list']);//获取权限列表
    Router::addRoute(["get","post"],'/permission/create', [App\Controller\Admin\PermissionsController::class,'create']);//创建权限
    Router::addRoute(["get","post"],'/permission/edit', [App\Controller\Admin\PermissionsController::class,'edit']);//修改权限
    Router::addRoute(["get","post"],'/permission/destroy', [App\Controller\Admin\PermissionsController::class,'destroy']);//删除权限

    //角色
    Router::addRoute(["get","post"],'/roles', [App\Controller\Admin\RolesController::class,'list']);//获取角色列表
    Router::addRoute(["get","post"],'/roles/detail', [App\Controller\Admin\RolesController::class,'detail']);//角色详情
    Router::addRoute(["get","post"],'/roles/create', [App\Controller\Admin\RolesController::class,'create']);//创建角色
    Router::addRoute(["get","post"],'/roles/update', [App\Controller\Admin\RolesController::class,'update']);//修改角色
    Router::addRoute(["get","post"],'/roles/destroy', [App\Controller\Admin\RolesController::class,'destroy']);//删除角色

    //管理员
    Router::addRoute(["get","post"],'/administrator', [App\Controller\Admin\AdministratorController::class,'administrator']);//获取当前管理员信息
    Router::addRoute(["get","post"],'/administrator/list', [App\Controller\Admin\AdministratorController::class,'list']);//获取管理员列表
    Router::addRoute(["get","post"],'/administrator/getCurrentAdministratorInfo', [App\Controller\Admin\AdministratorController::class,'getCurrentAdministratorInfo']);//获取当前管理员的信息
    Router::addRoute(["get","post"],'/administrator/create', [App\Controller\Admin\AdministratorController::class,'create']);//创建管理员
    Router::addRoute(["get","post"],'/administrator/getAdministratorInfo', [App\Controller\Admin\AdministratorController::class,'getAdministratorInfo']);//获取管理员的信息
    Router::addRoute(["get","post"],'/administrator/update', [App\Controller\Admin\AdministratorController::class,'update']);//修改管理员信息
    Router::addRoute(["get","post"],'/administrator/updatePassword', [App\Controller\Admin\AdministratorController::class,'updatePassword']);//修改管理员密码
    Router::addRoute(["get","post"],'/administrator/forbid', [App\Controller\Admin\AdministratorController::class,'forbid']);//封禁用户
    Router::addRoute(["get","post"],'/administrator/destroy', [App\Controller\Admin\AdministratorController::class,'destroy']);//删除用户
    Router::addRoute(["get","post"],'/administrator/setAdminRole', [App\Controller\Admin\AdministratorController::class,'setAdminRole']);//设置管理员的角色
},['middleware' => [\App\Middleware\Admin\VerifyTokenMiddleware::class]]);
